package command;

/**
 * 命令模式
 * <br> client 命令的调用者
 * <br> Command 命令
 * <br> Receiver 接收者
 * <br> Invoker 执行者
 */
public class CommandPatternDemo {
   public static void main(String[] args) {
      //receiver对象
      Stock abcStock = new Stock();
      abcStock.setName("测试");

      //command对象
      BuyStock buyStockOrder = new BuyStock(abcStock);
      SellStock sellStockOrder = new SellStock(abcStock);

      //根据传入order的不同，执行的命令也不同.Broker只负责执行Order命令
      //client对象
      Broker broker = new Broker();
      broker.takeOrder(buyStockOrder);
      broker.takeOrder(sellStockOrder);
 
      broker.placeOrders();
   }
}